package com.yang.inventorymanagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yang.inventorymanagement.pojo.Inventory;
import com.yang.inventorymanagement.service.InventoryService;
import com.yang.inventorymanagement.mapper.InventoryMapper;
import com.yang.inventorymanagement.mapper.InventoryMapper;
import com.yang.inventorymanagement.pojo.Inventory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Administrator
 * @description 针对表【inventory】的数据库操作Service实现
 * @createDate 2023-12-22 09:32:03
 */
@Service
public class InventoryServiceImpl extends ServiceImpl<InventoryMapper, Inventory>
        implements InventoryService {

    /**
     * 新数据
     *
     * @param inventory
     * @return
     */
    @Override
    public int insertInventory(Inventory inventory) {
        if (inventory == null) return 0;
        int insert = baseMapper.insert(inventory);
        return insert;
    }
    /**
     * 根据商品id查询所有库存信息
     * @param ProductID
     * @return
     */
    @Override
    public List<Inventory> getAllListInventory(Integer ProductID) {
        if (ProductID==null){
            return null;
        }
        QueryWrapper<Inventory> inventoryQueryWrapper = new QueryWrapper<>();
        inventoryQueryWrapper.eq("ProductID",ProductID);
        List<Inventory> inventories = baseMapper.selectList(inventoryQueryWrapper);

        return inventories;
    }
}




